//
//  CXSinglerModel.m
//  SmartCoin
//
//  Created by apple on 2018/3/7.
//  Copyright © 2018年 Cynic. All rights reserved.
//

#import "CXSinglerModel.h"

static dispatch_once_t predicate;
@implementation CXSinglerModel

+(instancetype)Defaultinit{
    static CXSinglerModel *model = nil;
    dispatch_once(&predicate,^{
//        CGFloat wid = cx_wid;
//        CGFloat hit = cx_hit;
        model = [[self alloc] init];
        model.DicData = [NSMutableDictionary dictionary];
        model.ArraryData = [NSMutableArray array];
        model.StrData = [NSMutableString string];
        model.topdis = cx_hit == 812 ? 44 : 20;
        model.bottomdis = cx_hit == 812 ? 34 : 0;
        model.navitop = cx_hit == 812 ? 0:20;
        model.loginrequest = [NSMutableDictionary dictionary];
        model.resp = [[UMSocialUserInfoResponse alloc] init];
        model.shouldRing = YES;
        model.allowed = NO;
        model.personData =  [@{
                                                       @"avatar": @"--",
                                                       @"balance":@"--",
                                                       @"bonusAmount":@"--",
                                                       @"empno":@"--",
                                                       @"id":@"--",
                                                       @"jobBonusState":@"--",
                                                       @"jobId":@"--",
                                                       @"jobRate":@"--",
                                                       @"mobile":@"--",
                                                       @"withdrawalAmount":@"--"
                                                       } mutableCopy];
        /*
         @property (nonatomic ,copy)NSString *openid;
         @property (nonatomic ,copy)NSString *phoneNumber;
         */
        model.MerchantSetting = [NSMutableDictionary dictionary];
        model.openid = @"";
        model.phoneNumber = @"";
        model.shopid = @"";
        model.companyname = @"";
        model.msgid = @"nilid";
        model.sellersegnum = 3;
    });
    return model;
}



+ (UIColor *)colorWithHex:(NSString *)hex alpha:(CGFloat)alpha
{
//    NSString *cleanString = [hex stringByReplacingOccurrencesOfString:@"#FF" withString:@""];
    NSString *cleanString = [hex stringByReplacingOccurrencesOfString:@"#" withString:@""];
    if([cleanString length] == 3) {
        cleanString = [NSString stringWithFormat:@"%@%@%@%@%@%@",
                       [cleanString substringWithRange:NSMakeRange(0, 1)],[cleanString substringWithRange:NSMakeRange(0, 1)],
                       [cleanString substringWithRange:NSMakeRange(1, 1)],[cleanString substringWithRange:NSMakeRange(1, 1)],
                       [cleanString substringWithRange:NSMakeRange(2, 1)],[cleanString substringWithRange:NSMakeRange(2, 1)]];
    }
    if([cleanString length] == 6) {
        cleanString = [cleanString stringByAppendingString:@"ff"];
    }
    unsigned int baseValue;
    [[NSScanner scannerWithString:cleanString] scanHexInt:&baseValue];
    
    float red = ((baseValue >> 24) & 0xFF)/255.0f;
    float green = ((baseValue >> 16) & 0xFF)/255.0f;
    float blue = ((baseValue >> 8) & 0xFF)/255.0f;
    
    return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
}



@end
